package com.zimin.cloud.system.controller.api;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zimin.authorize.annotation.Authorize;
import com.zimin.cloud.mine.pojo.system.business.RoleBO;
import com.zimin.cloud.system.pojo.entity.Role;
import com.zimin.shared.annotation.OpLog;
import com.zimin.shared.enums.ModuleEnum;
import com.zimin.shared.pojo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.Path;
import java.util.List;

/**
 * <p>
 * 角色信息 前端控制器 接口
 * </p>
 *
 * @author zimin
 * @since 2021-12-30 11:05
 */
@RequestMapping("/sys/role")
@Api(value = "角色信息API", tags = {"角色信息API"})
public interface IRoleController {

    /**
     * <p>查询角色列表</p>
     *
     * @param roleBO 查询参数
     * @return com.zimin.shared.pojo.Result
     * @since 2022-02-13 10:38:12
     */
    @GetMapping("/pageList")
    @Authorize(hasPerMi = "system:role:list")
    @OpLog(module = ModuleEnum.SYSTEM, action = "查询角色列表")
    Result rolePageList(Page<Role> rolePage, RoleBO roleBO);

    /**
     * 获取所有的角色
     */
    @GetMapping("/allRole")
    @Authorize(hasPerMi = "system:role:allRole")
    @OpLog(module = ModuleEnum.SYSTEM, action = "获取所有角色")
    @ApiOperation(value = "获取所有角色", notes = "获取所有角色", httpMethod = "GET")
    Result allRole();

    /**
     * 根据角色ID查询
     */
    @GetMapping("/{roleId}")
    @Authorize(hasPerMi = "system:role:findRole")
    @OpLog(module = ModuleEnum.SYSTEM, action = "根据ID查询角色")
    Result getRoleById(@PathVariable(name = "roleId") String roleId);

    /**
     * <p>保存角色</p>
     *
     * @param roleBO
     * @return com.zimin.shared.pojo.Result
     * @since 2022-02-14 15:55:52
     */
    @PostMapping
    @Authorize(hasPerMi = "system:role:save")
    @OpLog(module = ModuleEnum.SYSTEM, action = "保存角色")
    @ApiOperation(value = "保存角色", notes = "保存角色", httpMethod = "POST")
    Result save(@RequestBody @Validated RoleBO roleBO);

    /**
     * <p>修改角色</p>
     *
     * @param roleBO 角色对象
     * @return com.zimin.shared.pojo.Result
     * @since 2022-02-14 15:59:22
     */
    @PutMapping
    @Authorize(hasPerMi = "system:role:update")
    @OpLog(module = ModuleEnum.SYSTEM, action = "修改角色")
    @ApiOperation(value = "修改角色", notes = "修改角色", httpMethod = "PUT")
    Result update(@RequestBody @Validated RoleBO roleBO);

    /**
     * 批量删除角色
     */
    @DeleteMapping
    @Authorize(hasPerMi = "system:role:delete")
    @OpLog(module = ModuleEnum.SYSTEM, action = "批量删除角色")
    @ApiOperation(value = "批量删除角色", notes = "批量删除角色", httpMethod = "DELETE")
    Result delete(@RequestParam(value = "idList") List<String> idList);

}
